package com.ludomancy.spaceopera.entities;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;

import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.spaceopera.BasicEntity;
import com.ludomancy.spaceopera.Game;
import com.ludomancy.spaceopera.InventoryItem;
import com.ludomancy.spaceopera.Player;

public class Station extends BasicEntity
{
	private Image img;
	
	public static final int MAX_SLOTS = 8;
	public InventoryItem[] items = new InventoryItem[MAX_SLOTS];
	
	public Station(Point pos)
	{
		super(pos);
		img = ResourceManager.getImage("base.png");
		width = (int) proj.screenToWorldX(img.getWidth(null));
		height = (int) proj.screenToWorldY(img.getHeight(null));
	}
	
	public boolean hasItem(InventoryItem item)
	{
		for (int i = 0; i < items.length; i++)
		{
			if(items[i] == item)
			{
				return true;
			}
		}
		return false;
	}
	
	public void removeItem(InventoryItem item)
	{
		for (int i = 0; i < items.length; i++)
		{
			if(items[i] == item)
			{
				items[i] = null;
			}
		}
	}
	
	public void addItem(InventoryItem item)
	{
		for (int i = 0; i < items.length; i++)
		{
			if(items[i] == null)
			{
				items[i] = item;
				return;
			}
		}
	}
	
	public boolean isInteractable()
	{
		return true;
	}
	
	public void onPlayerInteraction(Player player)
	{
		Game.game.switchToStation();
	}
	
	public String getInteractionVerb()
	{
		return "Dock";
	}
	
	public void paint(Graphics g, int x, int y)
	{
		g.drawImage(img, x, y, null);
	}

}
